﻿// ***********************************************************************
// Assembly         : STX.Service
// Author           : seven.x
// Created          : 01-02-2014
//
// Last Modified By : seven.x
// Last Modified On : 01-03-2014
// ***********************************************************************
// <copyright file="BizAreaService.cs" company="驰创数码">
//     Copyright (c) 驰创数码. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************using System;

using System;
using System.Collections.Generic;
using System.Linq;
using Autofac;
using STX.Domain;
using STX.Domain.Report;
using STX.Repository;

namespace STX.Service
{
    /// <summary>
    /// Class BizAreaService.
    /// </summary>
    public class BizActivityService : BaseService<BizActivity>
    {
        public List<FinanceYear_HDMX> GetHdmxByYear(int year)
        {
            var list = new List<FinanceYear_HDMX>();
            for (var i = 1; i <= 12; i++)
            {
                var stime = new DateTime(year, i, 1);
                var etime = new DateTime(year, i, stime.LastDayOfMonth().Day);
                var monthData = (from s in FindAll()
                                 where s.EndTime >= stime && s.EndTime <= etime
                                 select s).ToList();
                list.Add(new FinanceYear_HDMX()
                {
                    DateByYear = stime,
                    HDZJE = monthData.Sum(o=>o.TotalQuotation+o.IncreaseOrDecrease),
                    WKPJE = monthData.Sum(o=>o.WKP),
                    YKPWSKJE = monthData.Sum(o=>o.YKPWSK),
                    YSKJE = monthData.Sum(o=>o.YSK)
                });
            }
            return list;
        }
    }
}
